<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Session;
use \think\Db;
class Version extends Common
{
	public function index(){

		$result = Db::name('version')->select();
		$this->assign('list',$result);
		return $this->fetch();
	}

	public function addversion(){
		return $this->fetch();
	}

	public function add(){
		$file = request()->file('pic');
        $data=array();
         if($file){
             $info = $file->rule('uniqid')->validate(['size'=>3000000000000,'ext'=>'apk'])->move(ROOT_PATH . 'public' . DS . 'static'. DS .'versions');
             $data=[
                'version_code'=>input('code'),
                'version_intro'=>input('intro'),
                'version_uptime'=>date('Y-m-d H:i:s'),
                'version_file'=>$info->getFilename(),
       		];
       		$result = Db::name('version')->insert($data);
       		if ($result) {
        		$this->success("发布成功",'version/index');
        	}
        	else{
        		$this->error("发布失败",'version/index');
        	}
        }else{
        	$this->error("发布失败",'version/index');
        }
	}

	
}